Skip to content

Fix incorrect URL generation in getContentUrl()#3759

Open
darth-antony wants to merge 1 commit intoStudio-42:masterfrom
darth-antony:fix/getContentUrl-path-bug
Open

Fix incorrect URL generation in getContentUrl()#3759
darth-antony wants to merge 1 commit intoStudio-42:masterfrom
darth-antony:fix/getContentUrl-path-bug

Conversation

@darth-antony
Copy link

trim($this->root, '/') strips the leading slash from the root path, making strlen() return a value 1 less than expected. This causes substr() to include an extra character from the root folder name in the relative path.

For example, with root folder "images":

  • Expected URL: /files/image.jpg
  • Actual URL: /files/s/image.jpg

Using strlen($this->root) + 1 is consistent with other URL construction methods in elFinderVolumeLocalFileSystem (lines 206, 612, 845, 1420) which all use this correct pattern.

Fixes #3746

trim($this->root, '/') strips the leading slash from the root path,
making strlen() return a value 1 less than expected. This causes
substr() to include an extra character from the root folder name
in the relative path.

For example, with root folder "images":
- Expected URL: /files/image.jpg
- Actual URL:   /files/s/image.jpg

Using strlen($this->root) + 1 is consistent with other URL
construction methods in elFinderVolumeLocalFileSystem (lines 206,
612, 845, 1420) which all use this correct pattern.

Fixes Studio-42#3746
@Smanst3r
Copy link

Any news on this https://github.com/Studio-42/elFinder/blob/master/php/elFinderVolumeDriver.class.php#L3334?
I have the same issue but I thought it could be done with rtrim($this->root..)... instead of trim($this->root...
and return rtrim($this->URL, '/') . $path;
Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

elfinder cannot open the file that has just been uploaded

2 participants